<include file="./Application/Home/View/public/header.html"/>
    <!-- topbar ends -->
<div class="ch-container">
    <div class="row">
        <!-- left menu starts -->
        <div class="col-sm-2 col-lg-2">
            <div class="sidebar-nav">
                <div class="nav-canvas">
                    <div class="nav-sm nav nav-stacked">

                    </div>
                    <ul class="nav nav-pills nav-stacked main-menu">
                        <li class="nav-header">功能</li>
                        <li><a class="ajax-link" href="{:U('poster')}"><i class="glyphicon glyphicon-home"></i><span> 主页</span></a>
                        </li>
                        <li><a class="ajax-link" href="{:U('posterList')}"><i
                                class="glyphicon glyphicon-align-justify"></i><span> 推送列表</span></a></li>
                        <li><a class="ajax-link" href="{:U('newPoster')}"> <i
                                class="glyphicon glyphicon-plus-sign"></i><span> 新增推送</span></a>
                        </li>
                         <li><a class="ajax-link" href="{:U('galleryList')}"><i class="glyphicon glyphicon-picture"></i><span> 图片列表</span></a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <!--/span-->
        <!-- left menu ends -->

        <noscript>
            <div class="alert alert-block col-md-12">
                <h4 class="alert-heading">Warning!</h4>

                <p>You need to have <a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
                    enabled to use this site.</p>
            </div>
        </noscript>

        <div id="content" class="col-lg-10 col-sm-10">
            <!-- content starts -->
            <div>
    <ul class="breadcrumb">
        <li>
            <a href="#">Home</a>
        </li>
        <li>
            <a href="#">Forms</a>
        </li>
    </ul>
</div>

<div class="row">
    <div class="box col-md-12">
        <div class="box-inner">
            <div class="box-header well" data-original-title="">
                <h2><i class="glyphicon glyphicon-edit"></i>推送详情预览</h2>
            </div>
            <div class="box-content">
                <div class="alert alert-info">推送详细信息</div>
                <br>
                <div class="form-group col-md-4">
                    <label class="control-label" for="post_title">推送标题</label>
                    <input type="hidden" name="post_id" id="post_id" <if condition="isset($data) eq true "> value="{$data.post_id}" </if>>
                    <input type="text" class="form-control" name="post_title"  placeholder="推送标题" id="post_title" <if condition="isset($data) eq true "> value="{$data.post_title}" </if>>
                </div>
                <div class="clearfix"></div>
                <div class="form-group col-md-12">
                	<label for="control-label"  for="post_desc">推送描述</label>
                	<input type="email" class="form-control" id="post_desc" placeholder="推送的描述" <if condition="isset($data) eq true "> value="{$data.post_desc}" </if>>
                </div>
                <div class="clearfix"></div>
                <div class="form-group  col-md-4">
                    <label class="control-label" for="status">推送状态</label>
                    <input data-no-uniform="true" name="status" id="status" type="checkbox" <if condition="isset($data) eq true and $data.status eq 1"> checked="checked" <else /> </if> class="iphone-toggle" >
                </div>
                <div class="clearfix"></div>
                <div class="form-group  col-md-4">
                    <label class="control-label" for="post_call">推送转发后跳转的页面</label>
                	<input type="email" class="form-control" id="post_call" placeholder="比如:http://www.baidu.com" <if condition="isset($data) eq true "> value="{$data.post_call}" </if> >
                </div>
                <div class="clearfix"></div>
                <div class="form-group  col-md-12">
                    <label class="control-label" for="">推送信息 <strong>(<a href="http://www.ipaiban.com/">微信编辑器</a>的排版代码)</strong></label>
                    <br/>
                    <textarea name="post_content" id="post_content" class="col-md-12" style="height:300px;">{$data.post_content}</textarea>
                </div>
                <div class="clearfix"></div>
                <div class="form-group  col-md-4">
                    <button class="btn btn-primary btn-lg" id="isOk">确定</button>
                    <button class="btn btn-primary btn-lg" id="pre" onclick="window.history.back();">返回</button>
                </div>
                <div class="clearfix"></div>
                <button class="btn btn-primary noty" style="display:none"
                        data-noty-options="{&quot;text&quot;:&quot;标题和内容不能为空&quot;,&quot;layout&quot;:&quot;top&quot;,&quot;type&quot;:&quot;error&quot;}">
                    <i class="glyphicon glyphicon-bell icon-white"></i> Top Right
                </button>
            </div>
        </div>
    </div>
    <!--/span-->

</div><!--/row-->
    <!-- content ends -->
    </div><!--/#content.col-md-0-->
</div><!--/fluid-row-->
<include file="./Application/Home/View/public/footer.html"/>
<script charset="utf-8" src="/Public/kindeditor-4.1.10/kindeditor-min.js"></script>
<script charset="utf-8" src="/Public/kindeditor-4.1.10/lang/zh_CN.js"></script>

<script>

    /*预览*/
    $("#perview").on("click",function(){
        location.href="{:U('posterPreview')}";
    });
    KindEditor.ready(function(K) {
        var options = {
            filterMode : false,
            allowFileManager : true
        };
        var editor = K.create('#post_content', options);

        /*确定*/
        $("#isOk").on("click",function(){
            var po_content = editor.html();
            var po_title = $('#post_title').val();
          
          
            if(!po_content || !po_title){
                $(".noty").click();
                return false;
            }
            var post_imgurl  = $($(".ke-edit-iframe")[0].contentWindow.document.body).find("img:first").attr("src");
            var params ={"post_id":$("#post_id").val(),"post_content":editor.html(),"post_title":$("#post_title").val(),'post_desc':$("#post_desc").val(),'post_call':$("#post_call").val(),'post_imgurl':post_imgurl,"status":$("#status").prop("checked")?1:0};
            $.ajax({ url:"{:U('posterPersist')}" , data: params, type: "post", dataType: "json", cache: false, async: true,
                success: function(data){
                    if(!!data && data.status){
                        $.IvanDialogOpen({
                            Type: 'tips',
                            Info: "推送添加成功",
                            Plugins: { CloseTime: 1200 }
                        });
                    }else{
                        $.IvanDialogOpen({
                            Type: 'tips',
                            Info: "推送添加失败",
                            Plugins: { CloseTime: 1200 }
                        });
                    }
                },
                error: function (XMLresponseText){
                    alert(XMLresponseText);
                }
            });
        });

    });
</script>